<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>粘性定位</title>
    <style>
        .u1 li:first-child{
            position: sticky;
            background-color: pink;
            top:-1px;
        }
        .u2 li:first-child{
            position: sticky;
            background-color: pink;
            top:-1px;
        }
        div{
            height:100px;
            overflow: scroll;
        }
    </style>
</head>
<body>
<div>
    <ul class="u1">
        <li>A</li>
        <li>a1</li>
        <li>a2</li>
        <li>a3</li>
        <li>a4</li>
    </ul>
    <ul class="u2">
        <li>B</li>
        <li>b1</li>
        <li>b2</li>
        <li>b3</li>
        <li>b4</li>
    </ul>
</div>

<script>

</script>
</body>
</html>